#include "util.h"
#include "biscuit.h"
#include "kfunc.h"

void
bzero (void * dest, unsigned int size) {
    while (size) {
        *((char*)dest) = 0;
        dest++;
        size--;
    }
}

void
memmove (void * dest, void * src, unsigned int size) {
    while (size) {
        *((char*)dest) = *((char*)src);
        *((char*)src) = 0;
        dest++;
        src++;
        size--; 
    }
}

void
memcpy (void *dest, void * src, unsigned int size) {
    while (size) {
        *((char*)dest) = *((char*)src);
        dest++;
        src++;
        size--; 
    }
}

int 
strcmp (void * s1, void * s2) {
    while (*((char*)s1) && *((char*)s2)) {
        if (*((char*)s1) != *((char*)s2))
            return -1;
        s1++;
        s2++;
    }
    if (*((char*)s1) || *((char*)s2))
        return -1;
    return 0;
}

void
strncpy (void * dest, void * src, unsigned int size) {
    unsigned int i;
    for (i = 0; i < size && *((char*)src) != 0; i++) {
        *((char*)dest) = *((char*)src);
        dest++;
        src++;
    }
    *((char*)dest) = 0;
}
